<?php
goto F7BaB;
bkGmk:
function fetchCards($card_id)
{
    goto dXezk;
    f0MRZ:
    if (empty($result)) {
        goto j8zg9;
    }
    goto kAama;
    JyKgS:
    $response = ihttp_request($url, json_encode($data));
    goto uvcs3;
    aysEr:
    return $result["card"];
    goto aFA3p;
    c2foS:
    s_UAs:
    goto sBwXv;
    lVZ5w:
    return error(-1, "访问公众平台接口失败, 错误: {$response["message"]}");
    goto c2foS;
    uvcs3:
    $apJqD = !is_error($response);
    goto fc1jH;
    dXezk:
    $token = getToken();
    goto hDAzm;
    g5P2E:
    $url = "https://api.weixin.qq.com/card/get?access_token={$token}";
    goto hDXOA;
    hDXOA:
    load()->func("communication");
    goto JyKgS;
    sBwXv:
    $result = @json_decode($response["content"], true);
    goto f0MRZ;
    NlU45:
    $data = array("card_id" => $card_id);
    goto g5P2E;
    fGP6L:
    j8zg9:
    goto NWZe_;
    NWZe_:
    return error(-1, "接口调用失败, 元数据: {$response["meta"]}");
    goto ZJE_c;
    CKcmU:
    goto zhwRQ;
    goto fGP6L;
    kAama:
    if (!empty($result["errcode"])) {
        goto xOfUn;
    }
    goto CKcmU;
    hDAzm:
    $h9tof = !is_error($token);
    goto GD8Xe;
    fc1jH:
    if ($apJqD) {
        goto s_UAs;
    }
    goto lVZ5w;
    GD8Xe:
    if ($h9tof) {
        goto uvwyh;
    }
    goto uzxEI;
    FRFUM:
    uvwyh:
    goto NlU45;
    ZJE_c:
    goto zhwRQ;
    goto wS94e;
    uzxEI:
    return $token;
    goto FRFUM;
    H11kp:
    return error(-1, "访问微信接口错误, 错误代码: {$result["errcode"]}, 错误信息: {$result["errmsg"]},错误详情：{}");
    goto IFaVO;
    wS94e:
    xOfUn:
    goto H11kp;
    IFaVO:
    zhwRQ:
    goto aysEr;
    aFA3p:
}
goto WKBWa;
PM7P0:
zJqc3:
goto ut2YH;
fJjas:
die(json_encode(array("status" => "2", "msg" => "没有需要更新的信息")));
goto npoN0;
bfq37:
function getToken()
{
    goto zNipY;
    DX6Dl:
    curl_close($curl);
    goto oql69;
    oql69:
    $data = json_decode($res, true);
    goto wSMA8;
    aKl6T:
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    goto xQZ6s;
    LdrbE:
    $mpinfo = pdo_get("mii_ang_setting", array("uniacid" => $_W["uniacid"]), array("appid", "appsecret"));
    goto qJASH;
    b35Gk:
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    goto PsyzL;
    dpT2p:
    $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
    goto FQYad;
    HDX5x:
    curl_setopt($curl, CURLOPT_URL, $url);
    goto N3Kz1;
    CIgEh:
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    goto b35Gk;
    FQYad:
    $curl = curl_init();
    goto HDX5x;
    zNipY:
    global $_W;
    goto LdrbE;
    qJASH:
    $appid = $mpinfo["appid"];
    goto iZTEg;
    xQZ6s:
    $res = curl_exec($curl);
    goto DX6Dl;
    iZTEg:
    $secret = $mpinfo["appsecret"];
    goto dpT2p;
    PsyzL:
    curl_setopt($curl, CURLOPT_TIMEOUT, 500);
    goto aKl6T;
    wSMA8:
    return $data["access_token"];
    goto M_S4p;
    N3Kz1:
    curl_setopt($curl, CURLOPT_HEADER, flase);
    goto CIgEh;
    M_S4p:
}
goto bkGmk;
rEFkm:
die(json_encode(array("status" => "2", "msg" => "该配置下没有可用的卡券")));
goto LowdY;
xFK5k:
function subcode($code)
{
    goto zcfS_;
    cXcbC:
    goto DtTze;
    goto YMdK5;
    kESWW:
    $codes = trim($codes);
    goto OUUhx;
    YMdK5:
    GJKCY:
    goto GPEC5;
    fNmrX:
    if (is_array($codeArr)) {
        goto GJKCY;
    }
    goto rxh1h;
    Pajzg:
    $rescode = "{" . $codestr . "}";
    goto cUJOz;
    GZq4w:
    return $rescode;
    goto yX47_;
    Pc77b:
    $codes = str_replace("\\", '', $codes);
    goto pUN9m;
    OUUhx:
    $codeArr = explode(",", $codes);
    goto fNmrX;
    rxh1h:
    $rescode = '';
    goto cXcbC;
    pUN9m:
    $codes = str_replace("[{", '', $codes);
    goto Vgi9Q;
    GPEC5:
    $codestr = $codeArr[0];
    goto Pajzg;
    Vgi9Q:
    $codes = str_replace("}]", '', $codes);
    goto kESWW;
    cUJOz:
    DtTze:
    goto GZq4w;
    zcfS_:
    $codes = str_replace("&quot;", "\"", $code);
    goto Pc77b;
    yX47_:
}
goto dvKzv;
xKOWR:
foreach ($card as $key => $v) {
    goto glbAh;
    R6Qo6:
    $cards["get_limit"] = $v[strtolower($v["card_type"])]["base_info"]["get_limit"];
    goto GFmmd;
    G78em:
    $cards["time_type"] = $v[strtolower($v["card_type"])]["base_info"]["date_info"]["type"];
    goto pTtwD;
    OZ47g:
    $res = 1;
    goto oSFMi;
    q50I2:
    $is_no = pdo_get("mii_ang_card", array("card_id" => $cards["card_id"]), array("id"));
    goto QFadn;
    WUJX2:
    $cards["total_quantity"] = $v[strtolower($v["card_type"])]["base_info"]["sku"]["total_quantity"];
    goto ODIZW;
    ODIZW:
    $cards["date_info"] = json_encode($v[strtolower($v["card_type"])]["base_info"]["date_info"]);
    goto E2i3I;
    ZtFYy:
    $cards["description"] = $v[strtolower($v["card_type"])]["base_info"]["description"];
    goto R6Qo6;
    gM3e5:
    $cards["card_id"] = $v[strtolower($v["card_type"])]["base_info"]["id"];
    goto ilI18;
    KnKAc:
    $res = pdo_update("mii_ang_card", $cards, array("card_id" => $cards["card_id"]));
    goto vVqEV;
    wfBBU:
    $res = '';
    goto Uxa5C;
    D2Rl1:
    $cards["title"] = $v[strtolower($v["card_type"])]["base_info"]["title"];
    goto w_yKB;
    S6Ncz:
    HFzjh:
    goto ESsNv;
    oSFMi:
    uw_QM:
    goto lkgvZ;
    PM4nO:
    $cards["notice"] = $v[strtolower($v["card_type"])]["base_info"]["notice"];
    goto Xi2du;
    dXTcQ:
    if ($res) {
        goto m4Og5;
    }
    goto eYY7G;
    w_yKB:
    $cards["bg_color"] = $v[strtolower($v["card_type"])]["base_info"]["color"];
    goto PM4nO;
    eYY7G:
    $res = '';
    goto nYQDP;
    nYQDP:
    goto YdneB;
    goto lhaRT;
    ESsNv:
    XVl80:
    goto vQzK5;
    n5X5X:
    Uy6xv:
    goto L7yB3;
    Xi2du:
    $cards["addtime"] = $v[strtolower($v["card_type"])]["base_info"]["create_time"];
    goto ZtFYy;
    GFmmd:
    $cards["starttime"] = $v[strtolower($v["card_type"])]["base_info"]["date_info"]["begin_timestamp"];
    goto Zo6Ck;
    Uxa5C:
    goto uw_QM;
    goto wNTPP;
    wNTPP:
    rt4Yo:
    goto OZ47g;
    QFadn:
    Upcard($v[strtolower($v["card_type"])]["base_info"]["id"], $v["card_type"]);
    goto fFn3p;
    lkgvZ:
    goto HFzjh;
    goto n5X5X;
    pTtwD:
    $cards["quantity"] = $v[strtolower($v["card_type"])]["base_info"]["sku"]["quantity"];
    goto WUJX2;
    L7yB3:
    $res = pdo_insert("mii_ang_card", $cards);
    goto dXTcQ;
    HThTA:
    $cards["uniacid"] = $_W["uniacid"];
    goto gM3e5;
    E2i3I:
    $cards["roof"] = "WECHAT";
    goto q50I2;
    vVqEV:
    if ($res) {
        goto rt4Yo;
    }
    goto wfBBU;
    lhaRT:
    m4Og5:
    goto dREqZ;
    ilI18:
    $cards["logo_url"] = $v[strtolower($v["card_type"])]["base_info"]["logo_url"];
    goto D2Rl1;
    dREqZ:
    $res = 1;
    goto H30dU;
    H30dU:
    YdneB:
    goto S6Ncz;
    fFn3p:
    if (empty($is_no)) {
        goto Uy6xv;
    }
    goto KnKAc;
    glbAh:
    $cards["card_type"] = $v["card_type"];
    goto HThTA;
    Zo6Ck:
    $cards["endtime"] = $v[strtolower($v["card_type"])]["base_info"]["date_info"]["end_timestamp"];
    goto G78em;
    vQzK5:
}
goto lzBf5;
NZLDg:
TaKfy:
goto X25oS;
F7BaB:
global $_W, $_GPC;
goto Ednhg;
AJxR5:
$cards = array();
goto xKOWR;
LowdY:
goto xhYiH;
goto mfruc;
WKBWa:
$card = json_decode(Getallcardlist(), true);
goto nTEp8;
X25oS:
die(json_encode(array("status" => "1", "msg" => "操作成功")));
goto RdII0;
wFiRp:
xhYiH:
goto PM7P0;
kZfLA:
die(json_encode(array("status" => "2", "msg" => "没有操作的权限")));
goto E6Qwg;
E6Qwg:
goto zJqc3;
goto T0gaT;
Ednhg:
if ($_W["role"] && $_W["isajax"]) {
    goto PRHI9;
}
goto kZfLA;
npoN0:
goto YmOV1;
goto NZLDg;
nTEp8:
if (is_array($card)) {
    goto IcKDi;
}
goto rEFkm;
mfruc:
IcKDi:
goto AJxR5;
v3QNB:
if ($res) {
    goto TaKfy;
}
goto fJjas;
gFc1U:
function Getallcardlist()
{
    goto vJ6QZ;
    h22vI:
    return json_encode($cardArray);
    goto OP8Eh;
    MD4wx:
    load()->func("communication");
    goto sCsz1;
    g0SD1:
    XUxaF:
    goto KJf0D;
    WFZLA:
    $cardArry = $resdata["card_id_list"];
    goto AMPad;
    Qr1f2:
    goto LoGZu;
    goto AOU5d;
    KJf0D:
    LoGZu:
    goto h22vI;
    sCsz1:
    $access_token = getToken();
    goto raLzS;
    AMPad:
    $cardArray = array();
    goto q5_Zx;
    q5_Zx:
    foreach ($cardArry as $key => $value) {
        goto Yz1Dh;
        Yz1Dh:
        $carddetailed = fetchCards($value);
        goto S56WL;
        S56WL:
        $cardArray[] = $carddetailed;
        goto tXaem;
        tXaem:
        Y_y8b:
        goto KvzLB;
        KvzLB:
    }
    goto g0SD1;
    Y2soq:
    $url = "https://api.weixin.qq.com/card/batchget?access_token=" . $access_token;
    goto QBxpM;
    PfJz5:
    $cardArray = array();
    goto Qr1f2;
    QBxpM:
    $res = ihttp_post($url, $post);
    goto YV_sc;
    p81v9:
    if ($resdata["errcode"] == 0 && $resdata["total_num"] > 0) {
        goto u0uWN;
    }
    goto PfJz5;
    AOU5d:
    u0uWN:
    goto WFZLA;
    vJ6QZ:
    load()->classs("weixin.account");
    goto MD4wx;
    raLzS:
    $post = "{\n\t\t\t  \"offset\": 0,\n\t\t\t  \"count\": 10, \n\t\t\t  \"status_list\": [\"CARD_STATUS_VERIFY_OK\",\"CARD_STATUS_DISPATCH\"]\n\t\t\t}";
    goto Y2soq;
    YV_sc:
    $resdata = @json_decode($res["content"], true);
    goto p81v9;
    OP8Eh:
}
goto xFK5k;
dvKzv:
function Upcard($card_id, $card_type)
{
    goto HF0gM;
    ajshW:
    $url = "https://api.weixin.qq.com/card/update?access_token={$access_token}";
    goto rMWxb;
    RbbzM:
    $cardid = $card_id;
    goto iVM0Q;
    afvdT:
    $access_token = getToken();
    goto BINUc;
    fGTdk:
    load()->classs("weixin.account");
    goto zxmp0;
    iVM0Q:
    $card_type = $card_type;
    goto afvdT;
    rMWxb:
    $res = ihttp_post($url, $post);
    goto ho2Rm;
    HF0gM:
    global $_W, $_GPC;
    goto fGTdk;
    zxmp0:
    load()->func("communication");
    goto RbbzM;
    BINUc:
    $post = "{\n\t\t                    \"card_id\":\"" . $cardid . "\",\n\t\t                    \"" . $card_type . "\": {\n\t\t                            \"base_info\": {\n\t\t                                    \"custom_url_name\": \"进入小程序\",\n\t\t                                    \"custom_url\": \"http://www.qq.com\",\n\t\t                                    \"custom_app_brand_user_name\": \"" . $_W["uniaccount"]["original"] . "@app\",\n\t\t                                    \"custom_app_brand_pass\":\"mii_ang/pages/index/index\",\n\t\t                                    \"custom_url_sub_title\": \"进入小程序\",\n\t\t                                    \"promotion_url_name\": \"小程序\",\n\t\t                                    \"promotion_url\": \"http://www.qq.com\",\n\t\t                                    \"promotion_app_brand_user_name\": \"" . $_W["uniaccount"]["original"] . "@app\",\n\t\t                                    \"promotion_app_brand_pass\":\"mii_ang/pages/index/index\"\n\t\t                            }\n\t\t\t                }\n\t\t\t    }";
    goto ajshW;
    ho2Rm:
    return $res["errmsg"];
    goto owtKF;
    owtKF:
}
goto bfq37;
T0gaT:
PRHI9:
goto gFc1U;
RdII0:
YmOV1:
goto wFiRp;
lzBf5:
E1pfh:
goto v3QNB;
ut2YH: